﻿
using UnityEngine;

public class CardMono : BundleInit
{

    public GameObject[] effects;
    private int curEffectIndex;
    private GameObject lastEffect;

    public override void Init()
    {
        if(effects == null || effects.Length == 0)
        {
            return;
        }
        
        ChangeToEffect(curEffectIndex);
    }

    private void Update()
    {
        if(effects == null || effects.Length == 0)
        {
            return;
        }

        if(Input.GetKeyDown(KeyCode.N))
        {
            curEffectIndex++;
            if (curEffectIndex > effects.Length - 1) curEffectIndex = 0;
            ChangeToEffect(curEffectIndex);
        }
    }

    private void ChangeToEffect(int index)
    {
        if(lastEffect != null && lastEffect.activeInHierarchy) lastEffect.SetActive(false);
        effects[index].SetActive(true);
        lastEffect = effects[index];
    }

    void OnDestroy()
    {

    }
}
